<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddressRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [

            'consignee' => 'required|max:60',
            //'country' => 'required|max:60',
            //'province' => 'required|max:60',
            'city' => 'required|max:60',
            'district' => 'required|max:120',
            'address' => 'required|max:120',
            'mobile' => 'required|size:11',
            'is_default' => 'in:0,1',
        ];
        return $rules;
    }

    public function messages()
    {
        return [

            'consignee.required' => '收货人不能为空',
            'consignee.max' => '收货人最大长度为60个字符',

            'city.required' => '城市不能为空',
            'city.max' => '城市最大长度为60个字符',

            'district.required' => '街道不能为空',
            'district.max' => '街道最大长度为120个字符',

            'address.required' => '详细地址不能为空',
            'address.max' => '详细地址最大长度为120个字符',

            'mobile.required' => '手机号码不能为空',
            'mobile.size' => '手机号码必须是11位',

            'is_default.in' => '默认地址的值不正确',
        ];
    }

}
